package com.gitee.sidihuo.utils.util;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;

@Slf4j
public class MdcUtils {

    public static String LOG_TRACE_KEY = "log-trace";

    public static void setLogTrace(String requestNo) {
        MDC.put(LOG_TRACE_KEY, requestNo);
    }

    public static String getLogTrace() {
        String requestNo = MDC.get(LOG_TRACE_KEY);
        return requestNo;
    }

    public static void removeLogTrace() {
        try {
            MDC.remove(LOG_TRACE_KEY);
        } catch (Throwable t) {
            log.warn("removeLogTrace ", t);
        }
    }

}
